package com.ruoyi.web.controller.tool;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JzArticleShop;
import com.ruoyi.system.service.IJzArticleShopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 旅游攻略关联表Controller
 * 
 * @author ruoyi
 * @date 2021-03-22
 */
@RestController
@RequestMapping("/system/article/shop")
public class JzArticleShopController extends BaseController
{
    @Autowired
    private IJzArticleShopService jzArticleShopService;

    /**
     * 查询旅游攻略关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(JzArticleShop jzArticleShop)
    {
        startPage();
        List<JzArticleShop> list = jzArticleShopService.selectJzArticleShopList(jzArticleShop);
        return getDataTable(list);
    }

    /**
     * 导出旅游攻略关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:export')")
    @Log(title = "旅游攻略关联表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JzArticleShop jzArticleShop)
    {
        List<JzArticleShop> list = jzArticleShopService.selectJzArticleShopList(jzArticleShop);
        ExcelUtil<JzArticleShop> util = new ExcelUtil<JzArticleShop>(JzArticleShop.class);
        return util.exportExcel(list, "shop");
    }

    /**
     * 获取旅游攻略关联表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jzArticleShopService.selectJzArticleShopById(id));
    }

    /**
     * 新增旅游攻略关联表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:add')")
    @Log(title = "旅游攻略关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JzArticleShop jzArticleShop)
    {
        return toAjax(jzArticleShopService.insertJzArticleShop(jzArticleShop));
    }

    /**
     * 修改旅游攻略关联表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:edit')")
    @Log(title = "旅游攻略关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JzArticleShop jzArticleShop)
    {
        return toAjax(jzArticleShopService.updateJzArticleShop(jzArticleShop));
    }

    /**
     * 删除旅游攻略关联表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:remove')")
    @Log(title = "旅游攻略关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jzArticleShopService.deleteJzArticleShopByIds(ids));
    }
}
